load("@rules_cc//cc:defs.bzl", "cc_toolchain")
load(":dummy_cc_toolchain.bzl", "dummy_cc_config", "dummy_cc_toolchain")

dummy_cc_toolchain(name = "dummy_cc_wasm32")

# When compiling Rust code for wasm32, we avoid linking to cpp code so we introduce a dummy cc
# toolchain since we know we'll never look it up.
# TODO(jedmonds@spotify.com): Need to support linking C code to rust code when compiling for wasm32.
toolchain(
    name = "dummy_cc_wasm32_toolchain",
    target_compatible_with = ["//rust/platform/cpu:wasm32"],
    toolchain = ":dummy_cc_wasm32_toolchain_cc",
    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)

cc_toolchain(
    name = "dummy_cc_wasm32_toolchain_cc",
    all_files = ":empty",
    compiler_files = ":empty",
    dwp_files = ":empty",
    linker_files = ":empty",
    objcopy_files = ":empty",
    strip_files = ":empty",
    supports_param_files = 0,
    toolchain_config = ":cc_toolchain_config",
    toolchain_identifier = "dummy_wasm32_cc",
)

dummy_cc_config(
    name = "cc_toolchain_config",
)

filegroup(
    name = "empty",
    srcs = [],
    visibility = ["//:__subpackages__"],
)
